home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The X-Philes (2nd Revision)
/
The X-Philes Number 1 (1995).iso
/
xphiles
/
hp48hor2
/
leastsq.doc
< prev
next >
Wrap
Text File
|
1995-03-31
|
3KB
|
75 lines
LEASTSQ - Least squares curve fitting
From: dnnant01@ucthpx.uct.ac.za (Anthony K. Donno)
Newsgroups: comp.sources.hp48
Date: 23 Sep 91 03:27:56 GMT
The feature that I use most in the HP48 stats menu is that of curve fitting,
however if you have data that does not fit the standard curve types offered
by the calculator, a good fit cannot be obtained.
The following program fits a polynomial equation to a set of data points in a
similar fashion to the stats menu. It takes a matrix off the stack that has at
least two columns in it (this is not checked), allows you to specify which
column is x data and which is y data, and then fits a curve to the data using
a polynomial of an order that you specify. Please note that more than 2
columns are allowed, but the program only works with the two that are
selected.
The program uses a standard least squares fit, but operates fairly quickly
(4.5 mins to fit a 15th order to 21 data pairs). Note that an option allows
you to specify whether the program must plot the fitted curve, or just return
the equation. The program does not recalculate the polynomial, unless you
change the x or y columns or the order of the polynomial required.
[If you want an exact polyfit (rather than least-squares approximation), see
POLYFIT on this disk. -jkh-]
The following menu is used:
XCOL - takes an integer off the stack and makes that column the x data
column
YCOL - takes an integer off the stack and makes that column the y data
column
ORDER - takes an integer off the stack and makes it the order of the poly-
nomial that is required
PLOT - calculates (if necessary) and plots the fitted polynomial
FIT - calculates (if necessary) and returns the polynomial that fits the
data
EXIT - returns back to the LEAST directory CST menu (you can put whatever
you want in this menu although a suggested menu is given)
The following is a list of the programs that make up LEAST:
LEAST - main program (menus ...)
PLOT - plotting function
FIT - curve fitter (brains)
POLY - converts a list of numbers on the stack into a algebraic polynomial
of the order given in level one (the numbers are the coefficients)
SETRNG - sets the range for the plot
XYR - redraws the top line of the LEAST screen (XCOL: 1 YCOL: 2 ORDER: 3)
DELEQ - deletes the current equation EQ
The following variables are produced by LEAST:
ORDR - order of the polynomial
YC - y data column
XC - x data column
dDAT - summation data (same as the stats menu)
EQ - current equation
Checksum : # 63743d
Bytes : 1950.5
I hope that this program is of use to others, and would appreciatiate it if
you would mail any comments to me.
==============================================================================
Anthony Donno |
Department of Electrical Engineering | Caesar entered on his head
University of Cape Town | he had a helmet on each foot
New South Africa | he had a sandal in his hand
| he had his trusty sword to boot
e-mail : dnnant01@ucthpx.uct.ac.za |
phone : +27 +21 6892420 |
==============================================================================